﻿@model List<TaskManager.Models.DepartmentModel>
@{
    ViewBag.Title = "Department";
}
@section breadcrumb
{
    <li>@Html.ActionLink("Department", "Index", "Department")</li>
}
<div class="row">
    <div class="col-xs-12">
        <div class="box">
            <div class="box-header">
                <h3 class="box-title">List Department</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body table-responsive">
                <a href="@Url.Action("Create")" class="btn btn-primary"><span class="glyphicon glyphicon-plus"></span> Add department</a>
                <table id="example2" class="table table-bordered table-hover">
                    <thead>
                        <tr>
                            <th>
                                Department Name
                            </th>
                            <th>
                                Leader
                            </th>
                            <th>
                                Created Date
                            </th>
                            <th style="width: 150px">Action
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in Model)
                        {
                            <tr>
                                <td>
                                    @item.Name
                                </td>
                                @if (item.User == null || item.UserId==0)
                                { 
                                    <td>
                                        
                                    </td>
                                }
                                else
                                {
                                    <td>
                                        @item.User.UserName - @item.User.FullName 
                                    </td>
                                }
                                <td>
                                    @item.CreatedDate
                                </td>
                                <td>
                                    @*@Html.ActionLink("Sửa", "Edit", new {id = item.Id}, new {@class ="btn btn-default btn-flat"}) 
                                    @Html.ActionLink("Xóa", "Delete", new {id = item.Id}, new {@class ="btn btn-default btn-flat"})*@
                                    <a class="btn btn-default btn-flat" href="@Url.Action("Edit",new {id = item.Id})"><i class="fa fa-edit"></i></a>
                                    <a class="btn btn-default btn-flat" href="@Url.Action("Delete",new {departmentId = item.Id})"><i class="fa fa-remove"></i></a>
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
            </div>
            <!-- /.box-body -->
        </div>
        <!-- /.box -->
    </div>
</div>
@section Script
{
    <script type="text/javascript">
        $(function () {
            $('#example2').dataTable({
                "bPaginate": true,
                "bLengthChange": false,
                "bFilter": false,
                "bSort": false,
                "bInfo": true,
                "bAutoWidth": false,
                "aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "Tất cả"]],
                "iDisplayLength": 25,
            });
        });
    </script>
}